package org.picommo.tests;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;
import org.picommo.common.Vec2;

public class ValueTypesTests {
	
	Vec2 v;
	double expectedLength;
	
	
	@Before
	public void setup() {
		v = new Vec2(10, -10);
		expectedLength = Math.sqrt(200.0);
	}
	
	
	@Test
	public void vec2Add() {
		Vec2 result = v.add(new Vec2(0, 5));
		assertEquals(new Vec2(10, -5), result);
		
		result = result.add(new Vec2(-10, -10));
		assertEquals(new Vec2(0, -15), result);
	}
	
	@Test
	public void vec2Length() {
		
		assertEquals(expectedLength*expectedLength, v.getLenghtSquared(), 0.00001);
		assertEquals(expectedLength, v.getLength(), 0.00001);
	}
	
	
	@Test
	public void vec2Normals() {
		
		assertEquals(new Vec2(10, 10), v.getLeftNormal());
		assertEquals(new Vec2(-10, -10), v.getRightNormal());
	}
	
	
	@Test
	public void vec2Zero() {
		assertEquals(new Vec2(0, 0), Vec2.getZero());
		assertTrue(Vec2.getZero().isZero());
	}
	
}
